package com.apps.ubc.cc;

import java.io.IOException;
import javax.servlet.http.*;

import com.apps.datastore.dao.UniqueCourseObject;
import com.apps.services.UBCSectionDetailService;

public class CourseInfoServlet extends HttpServlet {

	private String dept;
	private String course;
	private String section;

	private static UBCSectionDetailService wrapper = new UBCSectionDetailService();

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		dept = req.getParameter("dept").toUpperCase();
		course = req.getParameter("course");
		section = req.getParameter("section");
		UniqueCourseObject uco = new UniqueCourseObject(dept, course, section);
		int out = wrapper.initContent(uco);
		switch (out) {
		case 1:
			resp.sendRedirect("/courseInfo.jsp");
			break;
		case 0:
			resp.sendRedirect("/errorSTT.jsp");
			break;
		case -1:
			resp.sendRedirect("/error404.jsp");
			break;
		case -2:
			resp.sendRedirect("/error500.jsp");
			break;
		}

	}

	public String getDept() {
		return dept;
	}

	public String getSection() {
		return section;
	}

	public String getCourse() {
		return course;
	}

	public UBCSectionDetailService getWrapper() {
		return wrapper;
	}
}
